Template code generator